<!DOCTYPE html>
<html lang="zh" xmlns:th="http://www.thymeleaf.org" >
<head>
    <th:block th:include="include :: header('新增商城店铺信息')" />
    <th:block th:include="include :: datetimepicker-css" />
</head>
<body class="white-bg">
    <div class="wrapper wrapper-content animated fadeInRight ibox-content">
        <form class="form-horizontal m" id="form-shop-add">
            <div class="form-group">
                <label class="col-sm-3 control-label is-required">店铺名字：</label>
                <div class="col-sm-8">
                    <input name="shopName" class="form-control" type="text" required>
                </div>
            </div>
            <div class="form-group">
                <label class="col-sm-3 control-label is-required">工商登记号：</label>
                <div class="col-sm-8">
                    <input name="shopCertNo" class="form-control" type="text" required>
                </div>
            </div>
            <div class="form-group">
                <label class="col-sm-3 control-label is-required">负责人：</label>
                <div class="col-sm-8">
                    <input name="legalName" class="form-control" type="text" required>
                </div>
            </div>
            <div class="form-group">
                <label class="col-sm-3 control-label is-required">负责人证件号：</label>
                <div class="col-sm-8">
                    <input name="legalCertNo" class="form-control" type="text" required>
                </div>
            </div>
            <div class="form-group">
                <label class="col-sm-3 control-label is-required">负责人电话：</label>
                <div class="col-sm-8">
                    <input name="legalPhone" class="form-control" type="text" required>
                </div>
            </div>
            <div class="form-group">
                <label class="col-sm-3 control-label is-required">负责人户籍地址：</label>
                <div class="col-sm-8">
                    <input name="legalRegisteredAddress" class="form-control" type="text" required>
                </div>
            </div>
            <div class="form-group">
                <label class="col-sm-3 control-label is-required">负责人居住地址：</label>
                <div class="col-sm-8">
                    <textarea name="legalResidentialAddress" class="form-control" required></textarea>
                </div>
            </div>
            <div class="form-group">
                <label class="col-sm-3 control-label is-required">账户开户行：</label>
                <div class="col-sm-8">
                    <input name="openingBank" class="form-control" type="text" required>
                </div>
            </div>
            <div class="form-group">
                <label class="col-sm-3 control-label is-required">收款账户：</label>
                <div class="col-sm-8">
                    <input name="accountNumber" class="form-control" type="text" required>
                </div>
            </div>
            <div class="form-group">
                <label class="col-sm-3 control-label">店铺图片：</label>
                <div class="col-sm-8">
                    <div class="file-loading">
                        <input id="file" class="form-control" accept="image/jpg,image/jpeg,image/png" name="file"  type="file">
                        <img style="width: 80px ;height: auto;" src="" id="imgPhoto"  />
                        <input style="display: none"  id="photoUrl" class="form-control" name="photoUrl"   type="text">
                    </div>
                </div>
            </div>

            <div class="form-group">
                <label class="col-sm-3 control-label">店铺主页图片：</label>
                <div class="col-sm-8">
                    <div class="file-loading">
                        <input id="files" class="form-control" accept="image/jpg,image/jpeg,image/png" name="file"  type="file">
                        <img style="width: 80px ;height: auto;" src="" id="imgPhotos"  />
                        <input style="display: none"  id="photoUrls" class="form-control" name="photoUrls"   type="text">
                    </div>
                </div>
            </div>


        </form>
    </div>
    <th:block th:include="include :: footer" />
    <th:block th:include="include :: datetimepicker-js" />
    <script th:inline="javascript">
        var prefix = ctx + "mall/shop"
        $("#form-shop-add").validate({
            focusCleanup: true
        });



        $("input[name='joiningStartTime']").datetimepicker({
            format: "yyyy-mm-dd",
            minView: "month",
            autoclose: true
        });

        $("#file").bind('change', function () {
            $("#imgPhoto").show();
            $("#imgPhoto").attr("src",URL.createObjectURL($(this)[0].files[0]));
        });
        $("#files").bind('change', function () {
            $("#imgPhotos").show();
            $("#imgPhotos").attr("src",URL.createObjectURL($(this)[0].files[0]));
        });

        function uploadFile(idSelector,callback) {
            var formData = new FormData();
            formData.append('file',$(idSelector)[0].files[0]);
            $.modal.loading("图片上传中，请稍后...")
            $.ajax({
                url: "/common/admin/upload/up/single",
                data: formData,
                type: "post",
                dataType: "json",
                processData: false,
                contentType: false,
                success: function(result) {
                    $("#image").val(result.url);
                    // $.operate.save(prefix + "/add", $('#form-banner-add').serialize());
                    callback(result)
                }
            })
        }

        function submitHandler() {
            if ($.validate.form()) {

                uploadFile("#file",function (res) {
                    $("#photoUrl").val(res.url);

                    uploadFile("#files",function (res1) {
                        $("#photoUrls").val(res1.url);
                        $.operate.save(prefix + "/add", $('#form-shop-add').serialize());
                    })
                })
            }
        }


    </script>
</body>
</html>